<?php 
	namespace Home\Model;
	use Think\Model;
	class CarModel extends Model{
		protected $lassError='';
		public function getLastError(){
			return $this->lassError;
		}
		
		public function getCarList($page='1',$limit='10'){
			$carList=$this->page($page,$limit)->select();
			return $carList;
		}
		
		public function getCarCount(){
			$count=$this->count();
			return $count;
		}
		
		public function getCarById($carId){
			$carInfo=$this->where('car_id=%d',$carId)->find();
			if($carInfo=== null){
				$this->lassError='没找到内容';
				
			}
			if($carInfo=== false){
				$this->lassError='mysql 错误';
			}
			return $carInfo;
		}

		public function getFreeCarList($busyCarList,$page=1,$limit=10){
			if(empty($busyCarList)){
			  $freeCarList=$this->page($page,$limit)->select();
			  return $freeCarList;
			}
			 $freeCarList=$this->where('car_id not in (%s)',$busyCarList)->page($page,$limit)->select();
			return $freeCarList;
		}
		
	}